﻿Imports System.Web.UI
Imports System.Collections.Generic
Imports SISSAT.BusinessLayer.Views
Imports SISSAT.WebDevelopment.Views

Namespace Pages.Home
    Public Class Grades
        Inherits Page
        Implements IGradeView

        Property Presenter As GradePresenter
        Public Property IsUserAnInstructorForSchedule As Boolean Implements IGradeView.IsUserAnInstructorForSchedule

        Public Property StudentCode As String Implements IGradeView.StudentCode
            Get
                Dim code As String = HttpContext.Current.Request.QueryString("code")
                If String.IsNullOrEmpty(code) Then
                    code = SISSATPageBase.User.Employee.EmployeeCode
                End If

                Return code
            End Get
            Set(value As String)
                ' No logic
            End Set
        End Property

        Public WriteOnly Property RoomNumber As String Implements IGradeView.RoomNumber
            Set(value As String)
                roomNumberTextBox.Text = value
                roomNumberTextBox.ToolTip = value
            End Set
        End Property

        Public WriteOnly Property ScheduleDay As String Implements IGradeView.ScheduleDay
            Set(value As String)
                dayTextBox.Text = value
                dayTextBox.ToolTip = value
            End Set
        End Property

        Public WriteOnly Property ScheduleTime As String Implements IGradeView.ScheduleTime
            Set(value As String)
                timeTextBox.Text = value
                timeTextBox.ToolTip = value
            End Set
        End Property

        Public ReadOnly Property ScheduleId As Integer Implements IGradeView.ScheduleId
            Get
                Return Convert.ToInt32(HttpContext.Current.Request.QueryString("scid"))
            End Get
        End Property

        Public ReadOnly Property InstructorId As Integer Implements IGradeView.InstructorId
            Get
                Dim value As Boolean = _
                    String.Compare(SISSATPageBase.User.Employee.EmployeeType.Name, "Instructor", True) = 0

                Return Convert.ToInt32(IIf(value, SISSATPageBase.User.Employee.EmployeeId, 0))
            End Get
        End Property

        Public Event OnInitialization() Implements IGradeView.OnInitialization

        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            IsUserAnInstructorForSchedule = True

            Presenter = New GradePresenter(Me)
            RaiseEvent OnInitialization()

            GradeListControl.Visible = IsUserAnInstructorForSchedule
        End Sub

    End Class
End Namespace
